#include<stack>
#include<iostream>
class MyQueue {

public:
    std::stack<int> in;
    std::stack<int> out;
    MyQueue() {
        
    }

    void push(int x) {
        in.push(x);
    }

    int pop() {
        if (out.empty()) {
            while (!in.empty()) {
                int inpos = in.top();
                in.pop();
                out.push(inpos);
            }
        }
        int outtop = out.top();
        out.pop();
        return outtop;
    }

    int peek() {
        if (out.empty()) {
            while (!in.empty()) {
                int inpos = in.top();
                in.pop();
                out.push(inpos);
            }
        }
        return out.top();
    }

    bool empty() {
        return (in.empty() && out.empty());
    }
};

